import {request} from '@umijs/max';
import * as API from "@/services";
import {Activity_StatusModify} from "@/services";


/** 活动 分页检索请求 */
export async function queryActivitys(params: API.ActivityPageQueryParams): Promise<API.RespPageResult<API.Activity>> {
  return request('/api/v1/activity', {
    params,
  });
}

/** 活动 详情请求 */
export async function queryActivity(bizId: API.EntityId): Promise<API.RespResult<API.Activity>> {
  return request(`/api/v1/activity/${bizId}`);
}

/** 活动 创建请求 */
export async function createActivity(entity: API.Activity_Create): Promise<API.RespResult<any>> {
  return request(`/api/v1/activity`, {
    method: 'POST',
    data: entity,
  });
}

/** 活动 修改请求 */
export async function modifyActivity(entity: API.Activity_Modify): Promise<API.RespResult<any>> {
  return request(`/api/v1/activity/${entity.id}`, {
    method: 'PUT',
    data: entity,
  });
}

/** 活动 修改(部分)请求 */
export async function patchActivity(entity: API.Activity_Patch): Promise<API.RespResult<any>> {
  return request(`/api/v1/activity/${entity.id}`, {
    method: 'PATCH',
    data: entity,
  });
}

/** 活动 删除请求 */
export async function deleteActivity(bizId: API.EntityId): Promise<API.RespResult<any>> {
  return request(`/api/v1/activity/${bizId}`, {
    method: 'DELETE',
  });
}

/** 活动 批量删除请求 */
export async function deleteActivitys(bizIds: API.EntityId[]): Promise<API.RespResult<any>> {
  return request(`/api/v1/activity`, {
    method: 'DELETE',
    data: {
      ids: bizIds,
    },
  });
}


/** 活动 修改状态请求 */
export async function modifyActivityStatus(entity: API.Activity_StatusModify): Promise<API.RespResult<any>> {
  return request(`/api/v1/activity/modify-status/${entity.id}`, {
    method: 'PUT',
    data: entity,
  });
}

/** 活动 注册活动请求 */
export async function registerActivity(bizId: API.EntityId): Promise<API.RespResult<any>> {
  return request(`/api/v1/activity/register/${bizId}`, {
    method: 'PUT',
  });
}

/** 活动 取消活动请求 */
export async function cancelActivity(bizId: API.EntityId): Promise<API.RespResult<any>> {
  return request(`/api/v1/activity/cancel/${bizId}`, {
    method: 'PUT',
  });
}
